<!-- 产品轮播 -->
<template>
  <section class="swiper-container swiper-photo-pro">
    <article class="swiper-wrapper">
      <div class="swiper-slide" v-for="(item, index) in list" :key="index">
        <div class="imgBoxIn">
          <img :src="item" alt="" class="img" />
        </div>
      </div>
    </article>
    <!-- 分页器 -->
    <div class="swiper-pagination"></div>
  </section>
</template>

<script>
export default {
  /**
   * @list 图片数组
   */
  props: {
    list: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {
      mySwiper: null,
    };
  },
  computed: {},
  mounted() {
    this.initSwiper();
  },
  methods: {
    initSwiper() {
      this.$nextTick(() => {
        if (this.mySwiper && this.mySwiper.destroy) {
          this.mySwiper.destroy(true, true);
        }

        this.mySwiper = new Swiper(".swiper-photo-pro", {
          spaceBetween: 2,
          pagination: ".swiper-photo-pro .swiper-pagination",
          paginationClickable: true,
          autoplay: 8000,
          loop: true,
          autoplayDisableOnInteraction: false, //手动播放后继续自动播放
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.swiper-photo-pro {
  :deep(.swiper-pagination) {
    &-bullet {
      &-active {
        background-color: #e35191;
      }
    }
  }
}

.imgBoxIn {
  $wL: 370px;
  width: $wL;
 height: ($wL*210px)/370px;
  display: flex;
  justify-content: center;
  align-items: center;

  .img {
    max-width: 100%;
    max-height: 100%;
  }
  @media (min-width: 1441px) and (max-width: 1750px) {
    @function scale($currentSize) {
      @return calc(#{$currentSize} * #{$global_scale_1600});
    }
    $wL: 370px;
    width: $wL;
    height: (370px*210px)/370px;
  }
  @media screen and (min-width: 1100px) and (max-width: 1440px) {
    @function scale($currentSize) {
      @return calc(#{$currentSize} * #{$global_scale_1600});
    }
    $wL: 240px;
    width: $wL;
    height: (240px*210px)/370px;
  }
  @media (max-width: 767px) {
    @function scale($currentSize) {
      @return calc(#{$currentSize} * #{$global_scale_750});
    }
    $wL: 100%;
    width: $wL;
    height: $wL;
  }
}
</style>
